/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package argtrust.measure;

import argtrust.basics.ArgTrustException;

/**
 *
 * @author Yuqing Tang
 */
public class LevelMeasureOperators extends IMeasureOperators {

    double getLevel(Measure measure) //            throws ArgTrustException
    {
        if (!(measure.getOpMeasure() instanceof LevelMeasure)) {
            //TODO: throw an exception.
            System.err.println("DoubleMeasureComparator: Not a double-measurement");
            if (measure != null)
            {
                System.err.println("measure type:" + measure.getClass().getName());
            }
            try {
                throw new argtrust.basics.ArgTrustException("DoubleMeasureOperators: Not a double-measurement");
            } catch (argtrust.basics.ArgTrustException e) {
               e.printStackTrace();
            }
            System.exit(-1);
            return -1;
        }
        return ((LevelMeasure) measure.getOpMeasure()).getLevel();
    }


    public boolean eq(Measure lhs, Measure rhs) {
        return (getLevel(lhs) == getLevel(rhs));
    }

    public boolean lt(Measure lhs, Measure rhs) {
        return (getLevel(lhs) < getLevel(rhs));
    }

    public Measure oPlus(Measure lhs, Measure rhs)
    {
        return new LevelMeasure(getLevel(lhs) + getLevel(rhs));
    }
    public Measure oMul(Measure lhs, Measure rhs)
    {
        return new LevelMeasure(getLevel(lhs) * getLevel(rhs));
    }
    public Measure oDiv(Measure lhs, Measure rhs)
    {
        return new LevelMeasure(getLevel(lhs) / getLevel(rhs));
    }

}
